//
//  QSProblemProcessingViewController.m
//  DigitalEconomy_iOS
//
//  Created by Ding on 2020/3/19.
//  Copyright © 2020 DingC. All rights reserved.
//

#import "QSProblemProcessingViewController.h"
#import "QSProblemDataViewController.h"
@interface QSProblemProcessingViewController ()<VTMagicViewDataSource, VTMagicViewDelegate>
@property (nonatomic, strong)  NSArray *menuList;
@end

@implementation QSProblemProcessingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationItem.title = @"问题处理";
    self.view.backgroundColor = [UIColor colorWithHexString:@"#F1F3F4"];
    [self configSubView];
    [self addChildViewController:self.magicController];
    [self.view addSubview:self.magicController.view];
    [self generateTestData];
    [self.magicController.magicView reloadData];
    if (self.isDealFinish) {
        //返回按钮直接返回首页
        UIBarButtonItem *backBtn = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"ic_navigation_back"] target:self action:@selector(backHomeAction:)];
        self.navigationItem.leftBarButtonItem = backBtn;
    }
}


- (void)configSubView{
    
}

#pragma mark - 懒加载
- (VTMagicController *)magicController {
    if (!_magicController) {
        _magicController = [[VTMagicController alloc] init];
        _magicController.view.translatesAutoresizingMaskIntoConstraints = NO;
        _magicController.magicView.navigationColor = [UIColor whiteColor];
        _magicController.magicView.sliderColor = [UIColor colorWithHexString:@"#28A6FF"];
        _magicController.magicView.switchStyle = VTSwitchStyleDefault;
        _magicController.magicView.layoutStyle = VTLayoutStyleDivide;
        _magicController.magicView.sliderWidth = kRealValue(44);
        _magicController.magicView.separatorColor = [UIColor colorWithHexString:@"dddddd"];
        _magicController.magicView.navigationHeight = 44.f;
        _magicController.magicView.againstStatusBar = NO;
        _magicController.magicView.sliderExtension = 10.0;
        _magicController.magicView.dataSource = self;
        _magicController.magicView.delegate = self;
        _magicController.magicView.frame = CGRectMake(0, 0, kScreenWidth, kScreenHeight - kNavgationBarHeight);

    }
    return _magicController;
}

#pragma mark - VTMagicViewDataSource
- (NSArray<NSString *> *)menuTitlesForMagicView:(VTMagicView *)magicView {
    return _menuList;
}
    
- (UIButton *)magicView:(VTMagicView *)magicView menuItemAtIndex:(NSUInteger)itemIndex {
    static NSString *itemIdentifier = @"itemIdentifier";
    UIButton *menuItem = [magicView dequeueReusableItemWithIdentifier:itemIdentifier];
    if (!menuItem) {
        menuItem = [UIButton buttonWithType:UIButtonTypeCustom];
        [menuItem setTitleColor:[UIColor colorWithHexString:@"666666"] forState:UIControlStateNormal];
        [menuItem setTitleColor:[UIColor colorWithHexString:@"333333"] forState:UIControlStateSelected];
        menuItem.titleLabel.font = [UIFont fontWithName:@"Helvetica" size:14.f];
    }
    return menuItem;
}
    
- (UIViewController *)magicView:(VTMagicView *)magicView viewControllerAtPage:(NSUInteger)pageIndex {
    
    QSProblemDataViewController *dataVc = [[QSProblemDataViewController alloc] init];
    dataVc.index = pageIndex;
    return dataVc;
}
#pragma mark - functional methods
- (void)generateTestData {
    _menuList = @[@"待我处理", @"已办结的"];
}
- (void)backHomeAction:(UIButton *)sender{
    [UIApplication sharedApplication].keyWindow.rootViewController = [[QSMainTabBarController alloc] init];
}
@end
